﻿

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>OA传U8凭证日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

    <div class="layui-fluid">

        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">

                <div class="layui-form-item ">
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">流程编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="lcbh" id="lcbh" placeholder="请输入流程编号" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">制单人</label>
                        <div class="layui-input-block">
                            <select name="sel_zdr" id="sel_zdr" class="layui-form-select" lay-filter="sel_cm"></select>
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">开始日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" id="ksrq" placeholder="yyyy-MM-dd" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">结束日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" id="jsrq" placeholder="yyyy-MM-dd" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            <select name="status" id="status">
                                <option value="">全部</option>
                                <option value="0">成功</option>
                                <option value="1">失败</option>
                            </select>
                          
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg1">
                        <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>

            </div>

            <div class="layui-card-body">

                <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
                <script type="text/html" id="buttonTpl">
                    {{#  if(d.readstatus == '成功'){ }}
                    <button class="layui-btn layui-btn-xs">成功</button>
                    {{#  } else { }}
                    <button class="layui-btn layui-btn-danger layui-btn-xs">失败</button>
                    {{#  } }}
                </script>

                <script type="text/html" id="test-table-operate-td">
                    <a class="layui-btn layui-btn-xs" lay-event="post">查看详情</a>
                </script>

                <script type="text/html" id="imgTpl">
                    <img style="display: inline-block; width: 50%; height: 100%;" src={{ d.avatar }}>
                </script>
            </div>
        </div>
    </div>
    <script src="../../../layuiadmin/js/jquery.min2.1.4.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/js/jshelp.js"></script>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'laydate', 'useradmin', 'table', 'laypage'], function () {
            var $ = layui.$
                , form = layui.form
                , table = layui.table
                , laydate = layui.laydate
                , laypage = layui.laypage;


            //加载尺码信息
            $.ajax({
                type: "post",
                url: "ashx/list.ashx?type=get_zdr",
                dataType: "json",
                success: function (data) {
                    var html = '';
                    if (data.data.length == 0) {
                        html += "<option value=''>无数据</option>";
                        $("#sel_zdr").empty().append(html);
                    } else {
                        html += "<option value=''>请选择数据</option>";
                        for (var i = 0; i < data.data.length; i++) {
                            html += "<option value='" + data.data[i].zdr + "'>" + data.data[i].zdr + "</option>"
                        }
                        $("#sel_zdr").empty().append(html);
                    }
                    form.render('select');
                },
                error: function (data) {
                    layer.error(data);
                }
            });
            //当前时间
            function getNowtDay(d) {
                d = new Date(d);
                return new Date(d).format("yyyy-MM-dd");   //格式为"2019-02-16 00:00:00"
            };
            //当前加天数
            function getAddDay(d, t) {
                d = new Date(d);
                d = +d + (1000 * 60 * 60 * 24) * t;
                d = new Date(d);
                return new Date(d).format("yyyy-MM-dd");   //格式为"2019-02-16 00:00:00"
            };
            //当前减天数
            function getCutDay(d, t) {
                d = new Date(d);
                d = + d - (1000 * 60 * 60 * 24) * t;
                d = new Date(d);
                return new Date(d).format("yyyy-MM-dd");   //格式为"2019-02-16 00:00:00"
            };
            var date = new Date();
            var dt = getCutDay(date,1);


            //加载日期控件
            laydate.render({
                elem: '#ksrq'
                , value: dt
            });
            laydate.render({
                elem: '#jsrq'
            });
            var status =
                table.render({
                    elem: '#LAY-user-manage'
                    , id: 'testReload'//容器的ID
                    , url: 'ashx/list.ashx?type=getlist'
                    , toolbar: '#test-table-radio-toolbarDemo'
                    , method: 'POST'
                    , page: true
                    , limits: [10, 20, 30,50,100]
                    , limit: 10
                    , cols: [[
                        { type: 'checkbox' }
                        , { field: 'bxrq', width: 120, title: '报销日期', align: 'center' }
                        , { field: 'lcmc', width: 150, title: '流程名称', align: 'center' }
                        , { field: 'lcbh', width: 150, title: '流程编号', align: 'center' }
                        , { field: 'zdr', width: 100, title: '制单人', align: 'center' }
                        , { field: 'readstatus', width: 100, title: '状态', templet: '#buttonTpl', align: 'center' }
                        , { field: 'readtime', width: 200, title: '传输成功时间', align: 'center' }
                        , { field: 'readerror',  title: '失败原因', align: 'center' }
                        //, { width: 230, align: 'center', fixed: 'right', toolbar: '#test-table-operate-td' }

                    ]], parseData: function (res) { //将原始数据解析成 table 组件所规定的数据.
                        return {
                            "code": res.code, //解析接口状态
                            "msg": res.msg, //解析提示文本
                            "count": res.count, //解析数据长度
                            "data": res.data //解析数据列表
                        };
                    }
                    , where: {
                        lcbh: $('#lcbh').val(),
                        zdr: $("select[name='sel_zdr']").val(),
                        ksrq: $('#ksrq').val(),
                        jsrq: $('#jsrq').val(),
                        status: $("select[name='status']").val()
                    }
                });
            //监听排序
            table.on('sort(LAY-user-manage)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                table.reload('testReload', {//刷新列表
                    initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。 layui 2.1.1 新增参数
                    , where: { //请求参数
                        field: obj.field //排序字段
                        , order: obj.type //排序方式

                        , lcbh: $('#lcbh').val()
                        , zdr: $("select[name='sel_zdr']").val()
                        , ksrq: $('#ksrq').val()
                        , jsrq: $('#jsrq').val()
                        , status: $("select[name='status']").val()
                    }
                });
            });
            //双击行事件
            table.on('rowDouble(LAY-user-manage)', function (obj) {
                //console.log(obj.tr) //得到当前行元素对象
                //console.log(obj.data) //得到当前行数据
                layer.open({
                    type: 2
                    , title: '查看'
                    , content: 'select_mx.html?&lcbh=' + obj.data.lcbh
                    , maxmin: true
                    , area: [($(window).width() * 0.7) + 'px', ($(window).height() * 0.7) + 'px']
                    , cancel: function (index, layero) {

                    },
                    end: function () {

                    }
                });
                //obj.del(); //删除当前行
                //obj.update(fields) //修改当前行数据
            });
            //监听工具条
            table.on('tool(LAY-user-manage)', function (obj) {
                var data = obj.data;

                //传递人事系统
                if (obj.event === 'post') {
                    layer.confirm('您确定要传递吗', function (index) {
                        $.ajax({
                            url: 'ashx/list.ashx?type=post&getids=' + data.id,
                            type: "post",
                            contentType: "application/json",
                            dataType: "json",
                            data: {},
                            success: function (res) {

                                if (res.flag == "True") {
                                    layer.msg(res.remsg, {
                                        time: 2000,
                                        end: function () {
                                            table.reload('testReload', {//刷新列表
                                                where: { //请求参数
                                                    jlname: $('#jlname').val()
                                                    , ksrq: $('#ksrq').val()
                                                    , jsrq: $('#jsrq').val()
                                                }
                                            });
                                        }
                                    })
                                }
                                else {
                                    layer.alert(res.remsg);
                                }
                            }
                        });
                    });
                }

            });
            //事件
            var active = {

            };
            //监听搜索
            form.on('submit(LAY-user-front-search)', function (data) {
                var field = data.field;
                //执行重载
                table.reload('testReload', {
                    where: {
                        lcbh: $('#lcbh').val()
                        , zdr: $("select[name='sel_zdr']").val()
                        , ksrq: $('#ksrq').val()
                        , jsrq: $('#jsrq').val()
                        , status: $("select[name='status']").val()
                    }, page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            });
            function getRowFexId(value) {
                var checkStatus = table.checkStatus('testReload')
                    , data = checkStatus.data, arr = new Array();;
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i][value]);
                }
                return arr.join(",");
            }

            $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>
</html>
